package com.ruoyi.kaifa.controller;

import java.util.HashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kaifa.domain.AStanding;
import com.ruoyi.kaifa.service.IAStandingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.method.HandlerMethod;

/**
 * 身份信息Controller
 *
 * @author ruoyi
 * @date 2024-10-01
 */
@RestController
@RequestMapping("/kaifa/standing")
public class AStandingController extends BaseController {
    @Autowired
    private IAStandingService aStandingService;

    /**
     * 查询身份信息列表
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:list')")
    @GetMapping("/list")
    public TableDataInfo list(AStanding aStanding) {
        startPage();
        List<AStanding> list = aStandingService.selectAStandingList(aStanding);
        return getDataTable(list);
    }

    /**
     * 导出身份信息列表
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:export')")
    @Log(title = "身份信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AStanding aStanding) {
        List<AStanding> list = aStandingService.selectAStandingList(aStanding);
        ExcelUtil<AStanding> util = new ExcelUtil<AStanding>(AStanding.class);
        util.exportExcel(response, list, "身份信息数据");
    }

    /**
     * 获取身份信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(aStandingService.selectAStandingById(id));
    }

    /**
     * 新增身份信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:add')")
    @Log(title = "身份信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AStanding aStanding) {
        return toAjax(aStandingService.insertAStanding(aStanding));
    }

    /**
     * 修改身份信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:edit')")
    @Log(title = "身份信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AStanding aStanding) {
        return toAjax(aStandingService.updateAStanding(aStanding));
    }

    /**
     * 删除身份信息
     */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:remove')")
    @Log(title = "身份信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(aStandingService.deleteAStandingByIds(ids));
    }

    /**
    * 远程查询身份信息
    */
    @PreAuthorize("@ss.hasPermi('kaifa:standing:getStandingByName')")
    @GetMapping("/getStandingByName")
    public TableDataInfo getStandingByName(@RequestParam("name") String name){
        List<AStanding> aStandingList =  aStandingService.getAStandingList(name);
        return getDataTable(aStandingList);
    }
}
